<?php

namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;

use \GatewayWorker\Lib\Gateway;

use Illuminate\Support\Facades\DB;
use Cache;
use Validator;
use Carbon\Carbon;

use  App\Models\SMS;

class SMSController extends Controller
{
    public function create(Request $request)
    {
        $input = Input::only('content','phone_number','called_number','sended_at','is_send','imei');
        $validator = Validator::make($input, [        
            'content' => 'required',
            'phone_number' => 'nullable',
            'called_number' => 'nullable',
            'sended_at' => 'nullable',
            'is_send'  => 'nullable',
            'imei'  => 'nullable'
        ]);
        if ($validator->fails()) {
            return $this->returnError([],401,'参数错误');
        }
        // msg_type
        $data['content'] = $input['content'];
        $data['phone_number'] = $input['phone_number']??'';
        $data['called_number'] = $input['called_number']??'';
        $data['sended_at'] = $input['sended_at']??'';
        $data['is_send'] = $input['is_send']??0;
        $data['imei'] = $input['imei']??0;
        $res = SMS::create($data);
        return $this->returnOk([],'上传成功');
    }
}